<?php

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

/**
 * View class 
 */
class TaxiBookingViewOrders extends JView {

    function display($tpl = null) {
//		global $mainframe, $option;
               $app = JFactory::getApplication();
        //initialise variables
        $user = & JFactory::getUser();
        $db = & JFactory::getDBO();
        $document = & JFactory::getDocument();
        $lang = & JFactory::getLanguage();
     
        $groups = $user->get('groups');
        $gid = array_keys($groups);
        //only admins have access to this view
        if ($gid[0] != 8 && $gid[0] != 7) {
            JError::raiseWarning('SOME_ERROR_CODE', JText::_('ALERTNOTAUTH'));
            $app->redirect('index.php?option=com_taxibooking');
        }



        JHTML::_('behavior.tooltip');

        //get vars
//		$filter_order		= $mainframe->getUserStateFromRequest( $option.'.orders.filter_order', 		'filter_order', 	'datetime1', 'cmd' );
//		$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.'.orders.filter_order_Dir',	'filter_order_Dir',	'ASC', 'word' );
//		$filter_state 		= $mainframe->getUserStateFromRequest( $option.'.orders.filter_state', 		'filter_state', 	'*', 'word' );
//                $filter_payment		= $mainframe->getUserStateFromRequest( $option.'.orders.filter_payment', 		'filter_payment', 	'*', 'word' );
//		$search 		= $mainframe->getUserStateFromRequest( $option.'.orders.search', 			'search', 			'', 'string' );
//		$search 		= $db->getEscaped( trim(JString::strtolower( $search ) ) );
        //add css and submenu to document
        $document->addStyleSheet($this->baseurl . '/components/com_taxibooking/assets/css/booking.css');

        //Get data from the model
        $rows = & $this->get('Data');
        $pageNav = & $this->get('Pagination');

        $lists = array();

        $state = array();
        $state[] = JHTML::_('select.option', '', '- ' . JText::_('Select State') . ' -');
        $state[] = JHTML::_('select.option', 'P', JText::_('Accepted'));
        $state[] = JHTML::_('select.option', 'U', JText::_('Rejected '));
        $state[] = JHTML::_('select.option', 'A', JText::_('Archived'));
        $state[] = JHTML::_('select.option', 'W', JText::_('Waiting'));

        $lists['state'] = JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="this.form.submit();"', 'value', 'text', $filter_state);

        $payment_methods = array();
        $payment_methods[] = JHTML::_('select.option', '', '- ' . JText::_('Select Payment') . ' -');
        $payment_methods[] = JHTML::_('select.option', 'cash', JText::_('Cash'));
        $payment_methods[] = JHTML::_('select.option', 'paypal_confirmed', JText::_('Paypal (Confirmed)'));
        $payment_methods[] = JHTML::_('select.option', 'paypal_notconf', JText::_('Paypal (Not Confirmed)'));

        $lists['payment'] = JHTML::_('select.genericlist', $payment_methods, 'filter_payment', 'class="inputbox" size="1" onchange="this.form.submit();"', 'value', 'text', $filter_payment);


        // search filter
        $lists['search'] = $search;

        // table ordering
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;

        $ordering = ($lists['order'] == 'id');

        //assign data to template
        $this->assignRef('lists', $lists);
        $this->assignRef('rows', $rows);
        $this->assignRef('pageNav', $pageNav);
        $this->assignRef('ordering', $ordering);
        $this->assignRef('user', $user);
        $this->assignRef('direction', $lang);

        parent::display($tpl);
    }

}

?>